﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Directory.BLL
{
	internal sealed class BLLHelper
	{
		public static bool ValidateNotEmptyStringParameter(ref string parameter)
		{
			if (parameter == null)
			{
				return false;
			}
			parameter = parameter.Trim();
			if (parameter.Length == 0)
			{
				return false;
			}
			return true;
		}


		public static bool ValidateUserName(ref string username)
		{
			if (username == null)
			{
				return false;
			}
			username = username.Trim();
			if (username.Length < 1)
			{
				return false;
			}

			Regex reg = new Regex("\\w+@(\\w+.)+[a-z]{2,3}", RegexOptions.IgnoreCase);
			if (reg.IsMatch(username, 0))
			{
				return true;
			}
			return false;
		}

		public static bool ValidatePassword(ref string password)
		{
			if (password == null)
			{
				return false;
			}
			password = password.Trim();
			Regex reg = new Regex("^[A-Za-z0-9_-]{6,99}$", RegexOptions.IgnoreCase);
			if (reg.IsMatch(password))
			{
				return true;
			}
			return false;
		}
	}
}
